﻿<%@ WebHandler Language="C#" Class="shortcut" %>

using System;
using System.Web;
using System.IO;

public class shortcut : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        string fileName = "雨泽漫画.url";//客户端保存的文件名
        //string filePath = context.Server.MapPath("~/aspx/shortcut.txt");//路径

        ////以字符流的形式下载文件
        //FileStream fs = new FileStream(filePath, FileMode.Open);
        //byte[] bytes = new byte[(int)fs.Length];
        //fs.Read(bytes, 0, bytes.Length);
        //fs.Close();
        string s = "[{000214A0-0000-0000-C000-000000000046}]\r\n";
        s += "Prop3=19,2\r\n";
        s += "[InternetShortcut]\r\n";
        s += "URL=http://www.yzmanga.com/?desktop\r\n";
        s += "IconFile=http://www.yzmanga.com/support/naruto.ico\r\n";
        s += "IconIndex=0\r\n";
        s += "IconFile=C:\\WINDOWS\\system32\\SHELL32.dll\r\n";
        s += "IDList=\r\n";
        s += "HotKey=0\r\n";
        s += "[InternetShortcut.A]\r\n";
        s += "[InternetShortcut.W]\r\n";
        s += "[{000214A0-0000-0000-C000-000000000046}]\r\n";
        s += "Prop3=19,2\r\n";
        byte[] byteArray = System.Text.Encoding.Default.GetBytes(s);
        context.Response.ContentType = "application/octet-stream";
        //通知浏览器下载文件而不是打开
        context.Response.AddHeader("Content-Disposition", "attachment;  filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
        context.Response.BinaryWrite(byteArray);
        context.Response.Flush();
        context.Response.End();
    }


    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}